from fastapi import APIRouter

from app.core.responses import Response
from app.services.ad import AdServices

router = APIRouter(prefix="/ad")


@router.get("/", summary="获取广告")
async def index(name: str):
    data = AdServices.get_with_by_name(name)
    if not data:
        return Response.failed("广告不存在")
    return Response.success(data.serialize())
